package com.dave.dubbo.nacos.provider.service.impl;

import cn.hutool.core.date.DateUtil;
import com.dave.dubbo.provider.api.EmailService_ext_2_7_8;
import com.dave.dubbo.provider.api.entity.UserTest;
import com.dave.dubbo.provider.api.entity.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author wangwj
 * @version 1.0
 * @date 2022/1/27
 */
@Slf4j
@Component
@DubboService(version = "1.0.0")
public class EmailService_ext_Impl implements EmailService_ext_2_7_8 {

    @Override
    public String sendEmail(String title) {
        return String.format("扩展服务收到请求,%s", title);
    }

    @Override
    public UserTest sendEmail() {
        UserTest userTest = new UserTest();
        userTest.setId("3");
        userTest.setName("扩展服务收到请求");
        userTest.setDatetime(DateUtil.formatDateTime(new Date()));

        userTest.setUserVo(new UserVo("第一个", "第一个"));

        List<UserVo> list = new ArrayList<>();
        list.add(new UserVo("第二个", "第二个"));
        list.add(new UserVo("第三个", "第三个"));
        list.add(new UserVo("第四个", "第四个"));
        userTest.setList(list);
        return userTest;
    }

    @Override
    public String sendEmail(String title, String name) {
        return String.format("扩展服务收到请求,%s,%s", title, name);
    }
}
